<template>
	<view class="wp">
		<!-- <image :src="info.thumb" mode="widthFix"></image>
		<view class="buttons">
			<button @click="$navTo(info.url)">立即购买</button>
		</view> -->
		<view class="vip_info">
			<view class="vip_user" style="background-image: url('https://img.jinghushi.com/images/9/2024/06/x3fyrPI2f4zX3szry5z44UxIr9qJ92.png');">
				<view class="vip_date">有效期一年</view>
				<view class="vip_intro">
					<image :src="userInfo.member.avatar"></image>
					<view class="vip_desc">
						<view class="vip_name">{{userInfo.member.nickname}}</view>
						<view class="vip_blurb">享受VIP会员特权、商品折扣、VIP专区商品低至0元</view>
					</view>
				</view>
			</view>
		</view>
		<view class="vip_content">
			<view class="libao">
				<view class="li_tit">年费VIP会员+超值礼包</view>
				<view class="li_tip">超多商品折扣</view>
			</view>
			<scroll-view class="vip_level" scroll-x="true">
				<view class="vip_level_item" :class="{'vip_level_active':vipCurr==index}" v-for="(item,index) in vipGoodsList" @click="changeVip(index)">
					<view class="v_l_name">{{item.title}}</view>
					<view class="v_l_price"><text>￥</text>{{item.saleprice}}</view>
					<view class="v_l_old">原价￥{{item.marketprice}}一年</view>
				</view>
			</scroll-view>
			<!-- <view class="v_desc">不同价位礼包都可参与“VIP专区低至0元”活动<text @click="$navTo('/pages/user/vipShop')">查看活动 ></text></view> -->
			<view class="v_tip">不同价位礼包都可参与“VIP专区低至0元”活动</view>
			<view class="v_tip">同一个商品仅可享受一次优惠，请以实际支付价格为准</view>
			<view class="libao" @click="$navTo('/pages/user/vipShop')">
				<image style="width: 100%;" src="https://img.jinghushi.com/images/9/2024/06/lLWrPLRJ75CJj82wV1vBcWAE7RR828.png" mode="widthFix"></image>
			</view>
			<view class="libao">
				<view class="li_tit">礼包内容</view>
			</view>
			<view class="v_lift">
				<view class="v_lift_item" v-for="(item,index) in vipGoodsList[vipCurr].pics" @click="preview(index)">
					<!-- <view class="v_lift_left">
						<view class="v_lift_name">洗发水一份</view>
						<view class="v_lift_desc">海飞丝品牌</view>
					</view> -->
					<image :src="item" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<view class="xieyi">开通前请阅读<text @click="navto('https://bpapi.jinghushi.com/vip.html')">《VIP服务协议》</text></view>
		<view class="vip_buy">
			<view class="buy_left">
				<view class="vip_price"><text>￥</text>{{vipGoodsList[vipCurr].saleprice}}</view>
				<view>立省{{vipGoodsList[vipCurr].marketprice - vipGoodsList[vipCurr].saleprice}}元</view>
			</view>
			<view class="vip_btn" @click="toBuyReal">去支付</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: [],
				vipGoodsList: [],
				vipCurr: 0,
			}
		},
		onLoad() {
			this.getUserInfo();
			this.getVipGoodsList();
		},
		methods: {
			preview(index){
				uni.previewImage({
					urls: this.vipGoodsList[this.vipCurr].content,
					current: index
				})
			},
			changeVip(id){
				this.vipCurr = id;
			},
			toBuyReal(){
				if (!uni.getStorageSync('token')) {
					this.$refs.popup.open();
					return;
				}
				uni.navigateTo({
					url: '/pages/order/createOrder?type=3&id='+this.vipGoodsList[this.vipCurr].id+'&optionid=0&total=1&isVip=1'
				})
			},
			getUserInfo(){
				this.$axios('Center/main','POST','member').then(res=>{
					if(res.data.code == 200){
						this.userInfo = res.data.data;
					}
				})
			},
			getVipGoodsList(){
				this.$axios('home/vipgoodslist','POST','shop').then(res=>{
					if(res.data.code == 200){
						this.vipGoodsList = res.data.data.list;
					}
				})
			},
			navto(url) {
				if (url != "#" && url != "") {
					if (url.indexOf('http') == -1) {
						uni.navigateTo({
							url: url
						})
					} else {
						// #ifdef APP-PLUS || MP-WEIXIN
						uni.navigateTo({
							url: "../web/web-view?url=" + url
						})
						// #endif
						// #ifdef H5
						window.location.href = url
						// #endif
					}
				}
			},
			// getInfo() {
			// 	this.$axios('center/openVip', 'POST', 'member').then(res => {
			// 		if (res.data.code == 200) {
			// 			this.info = res.data.data;
			// 		}
			// 	})
			// }
		}
	}
</script>

<style lang="scss">
	.wp {
		padding-bottom: 186rpx;
	}
.vip_info{
	background: #393837;
	border-top: 1rpx solid #393837;
	border-radius: 38% / 30rpx;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
	height: 218rpx;
	overflow: hidden;
	.vip_user{
		width: 694rpx;
		height: 330rpx;
		background-size: 100% 100%;
		margin: 20rpx auto;
		position: relative;
		.vip_date{
			position: absolute;
			right: 0;
			top: 0;
			width: 166rpx;
			line-height: 50rpx;
			background: #F5DDBD;
			border-radius: 0rpx 29rpx 0rpx 29rpx;
			font-size: 24rpx;
			color: #875E2F;
			text-align: center;
		}
		.vip_intro{
			display: flex;
			padding: 40rpx;
			color: #412116;
			image{
				width: 88rpx;
				height: 88rpx;
				border-radius: 50%;
				margin-right: 20rpx;
			}
			.vip_desc{
				flex: 1;
				.vip_name{
					font-size: 36rpx;
					font-weight: 600;
					margin-bottom: 8rpx;
				}
				.vip_blurb{
					font-size: 24rpx;
					line-height: 34rpx;
				}
			}
		}
	}
}
.vip_content{
	padding: 40rpx 20rpx 20rpx;
	.libao{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
		.li_tit{
			font-size: 32rpx;
			font-weight: 600;
		}
		.li_tip{
			color: #999999;
			font-size: 24rpx;
		}
	}
	.vip_level{
		white-space: nowrap;
		.vip_level_item{
			display: inline-block;
			width: 200rpx;
			height: 256rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			border: 2rpx solid #DEDEDE;
			color: #77551E;
			text-align: center;
			margin-right: 20rpx;
			// padding: 0 10rpx;
			padding-top: 46rpx;
			.v_l_name{
				font-size: 24rpx;
				font-weight: 600;
				white-space: normal;
				height: 60rpx;
			}
			.v_l_price{
				font-weight: 600;
				font-size: 44rpx;
				margin: 16rpx 0;
				text{
					font-size: 24rpx;
				}
			}
			.v_l_old{
				color: #C6B299;
				font-size: 20rpx;
				text-decoration: line-through;
			}
		}
		.vip_level_active{
			background: #FDF3E7;
			border: 2rpx solid #E3B163;
		}
	}
	.v_desc{
		font-size: 24rpx;
		margin-top: 30rpx;
		margin-bottom: -10rpx;
		text{
			color: #8615E1;
			float: right;
		}
	}
	.v_tip{
		font-size: 24rpx;
		color: #999999;
		margin: 20rpx 0;
	}
	.v_lift{
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		.v_lift_item{
			width: 344rpx;
			height: 168rpx;
			// width: 100%;
			background: #F6F4F2;
			border-radius: 12rpx;
			display: flex;
			justify-content: space-between;
			// padding: 0 20rpx;
			margin-bottom: 20rpx;
			align-items: center;
			overflow: hidden;
			image{
				width: 100%;
				// height: 100%;
			}
			// .v_lift_left{
			// 	flex: 1;
			// 	.v_lift_name{
			// 		font-size: 32rpx;
			// 		font-weight: 600;
			// 		color: #412116;
			// 		margin-bottom: 10rpx;
			// 	}
			// 	.v_lift_desc{
			// 		color: #857068;
			// 		font-size: 24rpx;
			// 	}
			// }
		}
	}
}
.xieyi{
	background: #fbf8fe;
	color: #999;
	font-size: 24rpx;
	padding: 20rpx;
	text{
		color: $bg-color;
	}
}
.vip_buy{
	width: 100%;
	height: 186rpx;
	background: #FFFFFF;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0 20rpx;
	position: fixed;
	bottom: 0;
	.buy_left{
		display: flex;
		align-items: center;
		font-size: 24rpx;
		color: #999999;
		.vip_price{
			font-size: 44rpx;
			font-weight: 600;
			color: #77551E;
			margin-right: 10rpx;
			text{
				font-size: 32rpx;
			}
		}
	}
	.vip_btn{
		width: 354rpx;
		line-height: 94rpx;
		background: linear-gradient( 90deg, #F6E6C7 0%, #EED192 100%);
		border-radius: 47rpx;
		font-size: 32rpx;
		color: #412116;
		text-align: center;
		font-weight: 600;
	}
}
</style>